#ifdef __cplusplus
extern "C" {
#endif

#include "__str.h"
#include <string.h>
#include <stdio.h>
#include "Application.h"

__bsingleton(Application)

void __begheader(Application, initialize)
    HINSTANCE _tHandle
__begbody
    __this(Application)->mHandle = _tHandle;

    __this(Application)->mSystemDirectory = (char *)malloc(MAX_PATH);
	memset(__this(Application)->mSystemDirectory, '\0', MAX_PATH);
	::GetModuleFileNameA(NULL, __this(Application)->mSystemDirectory, MAX_PATH);

	int pos = strRfindeChar(__this(Application)->mSystemDirectory, '\\');
	for (int i = pos; i < MAX_PATH; i++)
	{
		__this(Application)->mSystemDirectory[i] = '\0';
	}
__endbody


void __begvoid(Application, showGraceful)
__begbody
    MSG msg;

    BOOL getMessage;
    while ((getMessage = ::GetMessage(&msg, (HWND) NULL, 0, 0)) != 0 && getMessage != -1) 
    { 
	    ::TranslateMessage(&msg);
	    ::DispatchMessage(&msg);
    }

__endbody


#ifdef __cplusplus
}
#endif

